<template>
	<view class="">
		<u-navbar title="订单中心" @leftClick="leftClick" :autoback="true"></u-navbar>
		<view class="flex-col space-y-20 section_3">
		  <view class="flex-row">
		    <text class="font_2">合同编号：</text>
		    <text class="font_3 text_5">{{contractNo}}</text>
		  </view>
		  <view class="group_4">
		    <text class="font_2">该合同下有</text>
		    <text class="font_3 text_7">{{total}}</text>
		    <text class="font_2 text_6">个订单</text>
		  </view>
		</view>
		<view class="" v-for="(item,index) in orders" :key="index">
			<ordercomp :infos="item"></ordercomp>
		</view>
	</view>
</template>

<script>
	import {getOrder} from '@/api/index.js'
	import ordercomp from '../../components/orderComp.vue'
	export default {
		components:{ordercomp},
		data() {
			return {
				orders:[],
				contractNo:'',
				total:0
			};
		},
		onLoad(option) {
			this.contractNo = option.contractNo;
			this.getInitData(option.contractNo)
		},
		methods:{
			leftClick(){
				if (getCurrentPages().length > 1) {
					uni.navigateBack();
				} else {
					uni.switchTab({
						url: '../../pages/index/index'
					})
				}
			},
			getInitData(contractNo){
				getOrder({pageSize:100,pageNo:1,contractNo:contractNo}).then(res => {
					if(res.code === 200) {
						this.orders = res.data.list;
						this.total = res.data.totalCount;
						// this.$u.toast('操作成功')
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.space-y-20 {
  & > view:not(:first-child),
  & > text:not(:first-child),
  & > image:not(:first-child) {
    margin-top: 20rpx;
  }
  .font_2 {
    font-size: 26rpx;
    font-family: Microsoft YaHei;
    line-height: 26rpx;
    color: #777777;
  }
  .font_3 {
    font-size: 26rpx;
    font-family: Microsoft YaHei;
    line-height: 21rpx;
    color: #444444;
  }
  .text_5 {
    margin-bottom: 3rpx;
  }
  .group_4 {
    align-self: flex-start;
    line-height: 26rpx;
    .text_7 {
      color: #f43738;
      line-height: 20rpx;
    }
    .text_6 {
      line-height: 25rpx;
    }
  }
}
.section_3 {
  padding: 29rpx 29rpx 36rpx;
  background-color: #ffffff;
}	
</style>